<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
<title>Document</title>
<link rel="stylesheet" href="../assets/agile/css/ratchet/css/ratchet.min.css">
<link rel="stylesheet" href="../assets/agile/css/flat/flat.component.css">
<link rel="stylesheet" href="../assets/agile/css/flat/iconline.css">
<link rel="stylesheet" href="../assets/app/css/app.css" />
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/jquery.js"></script>
<script type="text/javascript" src="../script/config.js"></script>
<script type="text/javascript" src="../script/local.js"></script>
<script type="text/javascript" src="../script/common.js"></script>
<style>li b span {
  padding-top: 10px;
}
li b span {
  width:25%;
  text-align:center;
  float: left;
}</style>
</head>
<body>
<!--通用顶部-->
<div id="ios-top-box">
    <div id="header" class="bar bar-nav">
    <div class="titlebar">
    <a href="javascript:appClose('createbuydetail',api);"><i class="iconfont iconline-arrow-left"></i></a>
    <h1 class="title">创团详情</h1>
    </div>
    </div>
</div>
<!--通用顶部结束-->
<section>
<div class="scroller">
	<ul class="listitem count_goods">
	        <li style="border-bottom:1px solid #ccc;">
	        <a href="javascript:;" class="goodstitle" style="display:inline-block;float:left;width:74px;height:74px;"><img data-original="" style="width:74px;height:74px;" class="img lazy"/></a>
	        <div class="text">
	                <p style="padding-left:10px;"><a href="javascript:;" class="goodstitle">加载中...</a></p>
					<p>&nbsp;&nbsp;价值：<em class="gray6 money" style="font-style: normal;">加载中...</em></p>
					<p>&nbsp;&nbsp;团名：<em class="blue q_group_name" style="font-style: normal;">加载中...</em></p>
					<div class="lottery" style="display:none;">
					<p>&nbsp;&nbsp;获得者：<em class="blue" style="font-style: normal;">加载中...</em></p>
					<p>&nbsp;&nbsp;揭晓时间：<em class="gray6" style="font-style: normal;">加载中...</em></p>
					</div>
				</div>
	        </li>
	        <li style="border-bottom:1px solid #ddd;">
	        <p>点击“立即邀请”分享链接和邀请码给好友进团夺宝</p>
	        <span style="display: block;" class="gray6 url">加载中...</span>
	        <span class="gray6">邀请码：<font class="codes">加载中...</font></span>
	        <div class="clear"></div>
				<button class="btn btn-positive btn1 shareBtn" style="width:50%;height:33px;background:#dd3e96;border:none;margin:10px auto !important;">
				<a href="javascript:;" style="color: #fff;" class="wxshareBtn">立即邀请</a>
				</button>
				<!-- <p><button style="float: right;margin-top:-42px;height:33px;line-height:33px;" class="common-btn view_detail"><a href="/?/mobile/mobile/tdataserver/<?php echo $shopinfo['id'];?>">开奖详情</a></button></p> -->
				<p><button style="float: right;margin-top:-42px;height:33px;line-height:33px;" class="common-btn view_detail jd"><a href="javascript:;">查看进度</a></button></p>
	        </li>
	</ul>
    <ul class="op">
       <li style="padding:8px;">
       	<span>本团商品您总共拥有<em class="orange" style="font-style: normal;">加载中... </em>个云购码</span>
       	<p class="gray9"><font class="time"></font>&nbsp;&nbsp;<span class="gonumber">加载中...人次</span></p>
       </li>
	    <li><b class="goucode">&nbsp;&nbsp;加载中...</b></li>
    </ul>
</div>
<input type="hidden" value="0" name="goods_id"/>
<input type="hidden" value="" name="lottery"/>
</section>
</body>
<script type="text/javascript">
apiready = function(){
	
	if(getUserinfo()){
		lyzimg();
		var team_goods_id = localData.get('team_goods_id');
		if(!team_goods_id){
			api.alert({msg:'参数错误'});
			return;
		}
		var userinfo = getUserinfo();
		GetJPData(config.url+'/app.php?act=createteam&uid='+userinfo.uid,{team_goods_id:team_goods_id},function(data){
			if(data['status'] == 1){
				if(data['lottery'] == 'yes'){
					$('.lottery .blue').text(data['shopinfo']['username']);
					$('.lottery .gray6').text(data['shopinfo']['q_end_time']);
					//$('.lottery').show();
					$('input[name=lottery]').val('yes');
				}else{
					$('input[name=lottery]').val('no');
				}
				$('input[name=goods_id]').val(data['shopinfo']['id']);
				$('li .img').attr('data-original',config.upload_url+'/'+data['shopinfo']['thumb']);
				$('p a.goodstitle').html(data['shopinfo']['title']);
				$('p em.money').text(data['shopinfo']['money']);
				$('p em.q_group_name').text(data['shopinfo']['q_group_name']);
				$('.op em.orange').text(data['data']['gonumber']);
				$('.op font.time').text(data['data']['time']);
				$('.op span.gonumber').text(data['data']['gonumber']+'人次');
				$('.op b.goucode').html(data['data']['goucode']);
				$('.codes').text(data['shopinfo']['q_create_pwd']);
				$('.url').text(data['shopinfo']['url']);
				lyzimg();
				
				$('.goodstitle').click(function(){
					var team_goods_id = $('input[name=goods_id]').val();
					if(team_goods_id == 0){
						api.alert({msg:'参数错误'});
						return;
					}
					localData.set('team_goods_id',team_goods_id);
					if($('input[name=lottery]').val() == 'no'){
						api.openWin({name:'team_item',url:'./team_item.html',reload:true});
					}else if($('input[name=lottery]').val() == 'yes'){
						api.openWin({name:'teamdataserver',url:'./team_dataserver.html',reload:true});
					}
					//获取 api.pageParam['team_goods_id']
				});
				
				$('.jd').click(function(){
					var team_goods_id = $('input[name=goods_id]').val();
					if(team_goods_id == 0){
						api.alert({msg:'参数错误'});
						return;
					}
					localData.set('team_goods_id',team_goods_id);
					api.openWin({name:'team_item',url:'./team_item.html',reload:true});
				});
				
				var shareData = {
					'share_title':'邀请码：['+data['shopinfo']['q_create_pwd']+'] '+data['shopinfo']['title'],
					'share_desc':data['shopinfo']['share_desc'],
					'share_img':config.upload_url+'/'+data['shopinfo']['thumb'],
					'share_link':data['shopinfo']['share_link']
				};
				$('.wxshareBtn').click(function(){
					var wx = api.require('wx');
		            wx.isInstalled(function(ret, err){
		                if(ret.installed){
		                    wx.shareWebpage({
		                        apiKey: config.wxpay.app_id,
		                        scene: 'session',
		                        title: shareData['share_title'],
		                        description: shareData['share_desc'],
		                        thumb: 'widget://res/_r1_c1.png',
		                        contentUrl: shareData['share_link'],
		                    }, function(ret, err){
		                        if(ret.status){
		                            appToast('分享成功');
		                        }else{
		                            //
		                        }
		                    });
		                }else{
		                    api.alert({msg:'当前设备未安装微信客户端'});
		                }
		            });
				});
				
			}else{
				api.alert({msg:data['msg']},function(index,err){
					localData.remove('team_goods_id');
					appClose('createbuydetail',api);
				});
			}
		});
	}else{
		$.PageDialog.fail('请登录用户');
	}
};
</script>
</html>